<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>老人入院登记表详情</title>
    <#include "/common/resource.ftl">
    <script type="text/javascript">
        $(function () {
            <#if (params.id)??>
                $.ajaxRequest({
                    url: '${params.contextPath}/web/elder/query',
                    data: {id: "${params.id}"},
                    success: function (data) {
                        if (!data.success) {
                            $.message(data.message);
                            return;
                        }
                        // 获取老人信息
                        var elder = data.data.elder;
                        for (var key in elder) {
                            $("[field='" + key + "']").html(elder[key]);
                        }

                        // 获取审批列表
                        var approvalResultList = data.data.approvalResultList;
                        var str = "";
                        var fileRequestUrl = '${params.fileRequestUrl}';
                        for (var i = 0; i < approvalResultList.length; i++) {
                            str += "<tr><td>"+ approvalResultList[i].username +"</td><td>"+ new Date(approvalResultList[i].createTime).format('yyyy-MM-dd HH:mm:ss') +"</td><td>"+ approvalResultList[i].content +"</td><td>"+ approvalResultList[i].statusStr +"</td>";
                            // 获取附件列表
                            var attachmentList = approvalResultList[i].attachmentList;
                            if (attachmentList != null && attachmentList.length > 0) {
                                str += "<td>";
                                for (var j = 0; j < attachmentList.length; j++) {
                                    str += '<a target="_blank" download="" style="text-decoration: underline; color: #0B61A4;" href="' + fileRequestUrl + attachmentList[j].path + '">'+ attachmentList[j].originalName + '</a>&nbsp;&nbsp;&nbsp;';
                                }
                                str += "</td>";
                            } else {
                                str += "<td></td>";
                            }
                            str += "</tr>";
                        }
                        if (str == "") {
                            str = "<tr><td colspan='4'>还没有任何审批记录!</td></tr>";
                        }
                        $("#approval").append(str);
                        <#if (params.tag)??>
                            $("[field='sex']").html(elder.sexStr);
                            $("[field='eduDegree']").html(elder.eduDegreeStr);
                            $("[field='maritalStatus']").html(elder.maritalStatusStr);
                        <#else>
                            if (elder.sex) {
                                var dictionaryOperator = DictionaryHelper.getDictionaryOperator("sex");
                                var sexName = dictionaryOperator.getDictionaryItemName(elder.sex);
                                $("[field='sex']").html(sexName);
                            }

                            if (elder.eduDegree) {
                                var dictionaryOperator = DictionaryHelper.getDictionaryOperator("degree");
                                var label = dictionaryOperator.getDictionaryItemName(elder.eduDegree);
                                $("[field='eduDegree']").html(label);
                            }

                            if (elder.maritalStatus) {
                                var dictionaryOperator = DictionaryHelper.getDictionaryOperator("maritalStatus");
                                var label = dictionaryOperator.getDictionaryItemName(elder.maritalStatus);
                                $("[field='maritalStatus']").html(label);
                            }
                        </#if>

                    }
                });
            </#if>
        });
    </script>
    <style>
        .layui-card-header{font-weight:bold;}
        .layui-table th{background-color:#f2f2f2 !important;width:120px;}
    </style>
</head>
<body style="background:#eee;">
<div style="padding:10px;">
    <div class="layui-card">
        <div class="layui-card-header">基本信息</div>
        <div class="layui-card-body">
            <table class="layui-table" lay-size1="sm">
                <tr>
                    <th>姓名</th>
                    <td field="name">--</td>
                    <th>性别</th>
                    <td field="sex">--</td>
                </tr>
                <tr>
                    <th>出生<br/>年月</th>
                    <td field="birthDate">--</td>
                    <th>文化<br/>程度</th>
                    <td field="eduDegree">--</td>
                </tr>
                <tr>
                    <th>政治<br/>面貌</th>
                    <td field="politicalOutlook">--</td>
                    <th>籍贯</th>
                    <td field="nativePlace">--</td>
                </tr>
                <tr>
                    <th>民族</th>
                    <td field="nation">--</td>
                    <th>婚姻<br/>状况</th>
                    <td field="maritalStatus">--</td>
                </tr>
                <tr>
                    <th>曾从事<br/>职业</th>
                    <td field="profession">--</td>
                    <th>户籍<br/>地址</th>
                    <td field="address">--</td>
                </tr>
                <tr>
                    <th>生日</th>
                    <td field="birthday">--</td>
                    <th>习惯就<br/>诊医院</th>
                    <td field="hospital">--</td>
                </tr>
                <tr>
                    <th>身份<br/>证号</th>
                    <td field="idcard" colspan="3">--</td>
                </tr>
                <tr>
                    <th>社保<br/>卡号</th>
                    <td field="socialCardNum" colspan="3">--</td>
                </tr>
                <tr>
                    <th>状态</th>
                    <td field="statusStr" colspan="3">--</td>
                </tr>
            </table>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-header">联系人信息</div>
        <div class="layui-card-body">
            <table class="layui-table" lay-size1="sm">
                <tr>
                    <th>第一<br/>联系人</th>
                    <td field="contactName1">--</td>
                    <th>联系人<br/>电话</th>
                    <td field="contactPhone1">--</td>
                </tr>
                <tr>
                    <th>第二<br/>联系人</th>
                    <td field="contactName2">--</td>
                    <th>联系人<br/>电话</th>
                    <td field="contactPhone2">--</td>
                </tr>
                <tr>
                    <th>第三<br/>联系人</th>
                    <td field="contactName3">--</td>
                    <th>联系人<br/>电话</th>
                    <td field="contactPhone3">--</td>
                </tr>
            </table>
        </div>
    </div>

    <div class="layui-card">
        <div class="layui-card-header">经济、健康情况、信仰</div>
        <div class="layui-card-body">
            <table class="layui-table" lay-size1="sm">
                <tr>
                    <th>经济<br/>来源</th>
                    <td field="incomeSource">--</td>
                    <th>宗教<br/>信仰</th>
                    <td field="faith">--</td>
                </tr>
                <tr>
                    <th>生活习惯<br/>兴趣爱好</th>
                    <td field="habit">--</td>
                    <th>主要病史<br/>药物过敏</th>
                    <td field="medicalHistory">--</td>
                </tr>
                <tr>
                    <th>备注</th>
                    <td field="remark" colspan="3">--</td>
                </tr>
            </table>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-header">入住信息</div>
        <div class="layui-card-body">
            <table class="layui-table" lay-size1="sm">
                <tr>
                    <th>入院号</th>
                    <td field="code">--</td>
                    <th>床位号</th>
                    <td field="bedNum">--</td>
                </tr>
                <tr>
                    <th>入住<br/>日期</th>
                    <td field="checkInDateStr">--</td>
                    <th>护理<br/>等级</th>
                    <td field="nursingLevelStr">--</td>
                </tr>
            </table>
        </div>
    </div>

    <div class="layui-card">
        <div class="layui-card-header">审批记录</div>
        <div class="layui-card-body">
            <table class="layui-table" lay-size1="sm" id="approval">
                <tr>
                    <th>审批人</th>
                    <th>审批时间</th>
                    <th>审批内容</th>
                    <th>审批状态</th>
                    <th>操作</th>
                </tr>
            </table>
        </div>
    </div>
</div>
</body>

</html>
